****************************************************************************
* File-Nale: 	codes_april.do
* Date:			02/01/2021
* Author: 		Fred Batista and Felipe Nunes
* Purpose: 		Analysis of March survey data
* Data used: 	dataapril.dta
* Data Output:	None	*/
****************************************************************************


***** RECODES

*** CONCERN ABOUR BRAZIL

* concern versus others

encode P1, gen(concernbr)

recode concernbr (4=1) (else=0)

* concern separated from revolt versus others

encode P1, gen(concernbr2)

recode concernbr2 (4=2) (5=1) (else=0)


*** COVID RELATED OPINIONS

* concern about COVID

encode P6, gen (worriedcov01)

recode worriedcov01 (1=0) (2=1) (3=2) (4=3) (5=3) (6=4) (7=.)

replace worriedcov01= worriedcov01/4

* main fear (fear of economy =1; fear of disease=0)

encode P7, gen(fearcov)

recode fearcov (1=1) (2=0) (3 4=.)

* social distancing view (maintain or keep for the elderly=1; suspend =0)

encode P8, gen(socdistkeep)

recode socdistkeep (1=0.5) (2=1) (3=.) (4=0)

* keep business shut (maintain indefinitely or for 15days = 1; open=0)

encode P9, gen(businessshut)

recode businessshut (1=1) (2=.) (3=0) (4=0.5)

* measures

polychoric businessshut socdistkeep

gen measures2 = (businessshut + socdistkeep)/2

*** OPINIONS ABOUT BRAZIL

* brazil�s getting better or worse (worse, nowhere and DK, better)

encode P2, gen(brabetterworse)

recode brabetterworse (1=2) (2=1) (3=0) (4=1)

gen brabetterworse01 = brabetterworse/2


*** OPINIONS ABOUT BOLSONARO

* evaluation of bolsonaro�s job performance

encode P4, gen(approval)

recode approval (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

gen approval01 = approval/5

* bolsonaro�s admin better or worse than expected (Dk combined as middle)

encode P5, gen(bolsoexp)

recode bolsoexp (1=2) (2 3=1) (4=0)

gen bolsoexp01 = bolsoexp/2

* 2018 vote (null and absent as neutral category)

encode P30, gen(vote18)

gen haddadvoter = vote18

recode haddadvoter (2=1) (else=0)

gen bolsovoter = vote18

recode bolsovoter (3=1) (else=0)

* 2022 vote (DK as neutral category)

encode P32, gen(vote22)

gen haddadfuture = vote22

recode haddadfuture (1=1) (else=0)

gen bolsofuture = vote22

recode bolsofuture (2=1) (else=0)

* general feelingsabout bolsonaro (similar to March)

polychoric approval01 bolsoexp01 bolsovoter bolsofuture

alpha approval01 bolsoexp01 bolsovoter bolsofuture, std

gen bolsoeval = (approval01 + bolsoexp01 + bolsovoter + bolsofuture)/4

* feeling thermoeter (not in March)

encode P25, gen(bolsofeeling)

recode bolsofeeling (6=0) (5=.) (4=1) (3=2) (2=3) (1=4)

replace bolsofeeling = bolsofeeling/4

* MORO EPISODE

encode P14, gen(bolsovmoro1)

recode bolsovmoro1 (4=.5) (5=0) (6=1)

encode P15, gen(bolsovmoro2)

recode bolsovmoro2 (3=0.5) (4=1) (5=0)

encode P16, gen(bolsovmoro3)

recode bolsovmoro3 (4=0) (5=1) (2=.5)

encode P17, gen(bolsovmoro4)

recode bolsovmoro4 (1=.5) (2=1) (3=0)

encode P18, gen(bolsovmoro5)

recode bolsovmoro5 (1=0) (2=1) (3 4=.5)

polychoric bolsovmoro1 bolsovmoro2 bolsovmoro3 bolsovmoro4 bolsovmoro5

alpha bolsovmoro1 bolsovmoro2 bolsovmoro3 bolsovmoro4 bolsovmoro5

gen bolsovmoro = (bolsovmoro1 + bolsovmoro2 + bolsovmoro3 + bolsovmoro4 + bolsovmoro5)/5


* CONTROLS

* most trustworthy information source

encode P35, gen(infosource)

gen sourcetv = infosource

recode sourcetv (1=1) (else=0)

gen sourcetv2 = infosource

recode sourcetv2 (1 2 3 4=1) (else=0)

gen sourcenet = infosource

recode sourcenet (5 6=1) (else=0)

gen mediachoice = infosource

recode mediachoice (1=1) (5 6=2) (else=0)

* religion

encode P36, gen(religion)

gen catholic = religion

recode catholic (1=1)(else=0)

gen protestant = religion

recode protestant (2 6=1) (else=0)

* ideologia (higher is right)

encode P28, gen(ideo)

recode ideo (1=0) (2=1) (3=10) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9)

gen ideo01 = ideo/10

* income

encode P37, gen(income)

recode income (1=0) (2=1) (3=5) (4=6) (5=2) (6=3) (7=4) (8=7) (9=.)

gen income01 = (income)/7

* sex (male=1)

encode AL, gen(male)

replace male = male - 1

* age

encode AM, gen(age)

gen age01 = (age-1)/61

* region

encode AN, gen(region)

* social class

encode AO, gen(class)

recode class (6=.)

replace class = 5 - class

gen class01= class/4


*** DESCRIPTIVES

summarize worriedcov01 measures fearcov bolsoeval 1.mediachoice 2.mediachoice 0.mediachoice age01 ideo01 catholic protestant income01 male 1.region 2.region 3.region 4.region 5.region 

pwcorr concernbr worriedcov01 measures fearcov, sig


*** ANALYSES

* correlates of mediachoice

mprobit mediachoice bolsoeval age01 ideo01 catholic protestant income01 male i.region, base(0)


* corelates of concern

reg worriedcov01 bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region

margins, dydx(mediachoice)

reg worriedcov01 c.bolsoeval##i.mediachoice age01  ideo01 catholic protestant income01 male i.region

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Concern About Covid-19", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(april1)


* correlates of support for measures

reg measures bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region

margins, dydx(mediachoice)


reg measures c.bolsoeval##i.mediachoice bolsoeval age01  ideo01 catholic protestant income01 male i.region

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Support for Measures", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(april2)


* combining graphs

grc1leg april1.gph april2.gph, title({bf:April}, size(vlarge)) plotregion(style(none)) graphregion(color(white)) rows(1) iscale(1) name(april)

graph display april, ysize(6) xsize(10)


* correlates of economic fear

probit fearcov bolsoeval i.mediachoice age01 ideo01 catholic protestant income01 male i.region

margins, at(mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(none)) ci1(lcolor(black) msize(vtiny)) ytitle("", height(7)) xtitle(" ") xlabel(0.5 " " 1 "TV" 2 "Internet" 2.5 " ", noticks labsize(large)) title({bf:April}, size(large)) ylabel(0(.1).50,nogrid) yscale(noextend)  plotregion(style(none)) graphregion(color(white)) ysize(8) xsize(8) saving(econ1april)


margins, at(bolsoeval=(0(.1)1))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title({bf:April}, size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(econ2april)

*******

* replacing info source by madiachoice

reg worriedcov01 c.bolsoeval##i.infosource age01  ideo01 catholic protestant income01 male i.region


reg measures c.bolsoeval##i.infosource bolsoeval age01  ideo01 catholic protestant income01 male i.region


****** END OF CODE
